#+title: Keyamp
#+author: Egor Maltsev

Input model based on [[file:packages/keyamp.el][Keyamp]] for Emacs.

** Keyboard Layouts
- ANSI keyboard
- Virtual keyboard
- Split keyboard

* ANSI keyboard

- [[file:karabiner/karabiner.json][Karabiner]] config file. Emacs Keyamp mode integration
- [[http://www.keyboard-layout-editor.com/#/gists/106550cd49793787784ed1b9c9117c3d][Layout]] based on [[file:layouts/Engram.bundle][Engineer Engram]]:
- Automatic Russian layout support for command bindings

[[screenshots/ansi-keyboard.png]]

#+begin_src bash
brew tap xEgorka/emacsmacport
brew install emacs-mac --with-natural-title-bar --with-native-comp
defaults write org.gnu.Emacs TransparentTitleBar DARK
defaults write org.gnu.Emacs HideDocumentIcon YES
#+end_src

[[screenshots/desktop.png]]

[[screenshots/desktop2.png]]

*** Titlebar
#+begin_src elisp
(when (display-graphic-p)
  (setq display-time-default-load-average nil
        battery-mode-line-format "%b%p%%   "
        display-time-format "%a %e %b %R"
        ns-use-proxy-icon nil
        icon-title-format t)
  (setq frame-title-format
        (list (make-string 200 ?\t) 'battery-mode-line-string 'display-time-string))
  (display-battery-mode)
  (display-time-mode))
#+end_src

*** Modeline on top
#+begin_src elisp
(defvar selected-window nil "Selected window.")

(defun selected-window-save ()
  "Keep `selected-window'."
  (setq selected-window (selected-window)))

;; display mode indicator for selected window only
(when terminal-p
  (add-hook 'post-command-hook 'selected-window-save)
  (add-hook 'buffer-list-update-hook (lambda () (force-mode-line-update t))))

(setq-default mode-line-format nil
              header-line-format
              (list
               ""
               ;; mode indicator
               (when terminal-p
                 '(:eval
                   (if (eq selected-window (selected-window))
                       'mode-line-front-space
                     "")))
               ;; buffer name
               '(:eval (propertize " %b"
                                   'face
                                   (if (and (buffer-modified-p) (buffer-file-name))
                                       'font-lock-string-face
                                     'font-lock-builtin-face)
                                   'help-echo
                                   (buffer-file-name)))

               ;; branch
               '(:eval (when
                           (and vc-mode
                                (not (or (string-equal (substring vc-mode 5) "master")
                                         (string-equal (substring vc-mode 5) "main"))))
                         (list " @" (substring vc-mode 5))))
               ;; align right spacer
               '(:eval (propertize
                        " " 'display
                        `((space :align-to
                                 (- (+ right right-fringe right-margin)
                                    ,(+ (length (format-mode-line "%l:%c "))))))))
               ;; position in buffer
               '(:eval (propertize "%l:%c " 'face 'font-lock-builtin-face))))
#+end_src

* Virtual keyboard

Emacs in pocket with unicode support. [[https://apps.apple.com/us/app/termius-terminal-ssh-client/id549039908][Termius]] client. Custom keyboard.

*** Custom
- Engineer Engram and Russian layouts
  - [[https://apps.apple.com/us/app/xkeyboard-custom-keyboard/id1440245962][xKeyboard - Custom Keyboard]]
  - Layout file: [[file:layouts/Engineer-Engram.xkeyboard][Engineer-Engram.xkeyboard]]

*** Preferences
- Set terminal and keyboard coding system to utf-8:
#+begin_src elisp
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
#+end_src

[[screenshots/virtual-keyboard.png]]

- Emacs in tmux over mosh - instant remote access
#+begin_src bash
  mosh-server new -s -c 256 -l LANG=en_US.UTF-8 -- tmux -u new -As0 'emacs'
#+end_src

- Use [[https://github.com/justbur/emacs-which-key][which-key]] for binding completion
- Emacs in [[https://ish.app/][iSH]] - offline local access on iOS from Termius
- Nord theme for Emacs and Termius
- Color mode indicators

* Split keyboard

- Kinesis Advantage2 [[http://www.keyboard-layout-editor.com/#/gists/6a1a62133ab9f741589bd556cb946792][layout]] and [[file:layouts/qwerty2.txt][config]]:

[[screenshots/advantage2.png]]

- Vimium mappings: [[file:layouts/vimium-options.json][vimium-options.json]]
